package cn.bdqn.web;

import cn.bdqn.service.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delete")
public class CustomerDeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 接收 cid 字段
        String cid = request.getParameter("cid");
        CustomerServiceImpl customerService = new CustomerServiceImpl();

        boolean flag = customerService.deleteById(Long.parseLong(cid));
        // System.out.println(flag);
        if(flag){
            request.getRequestDispatcher("/customer").forward(request,response);
        }
    }
}
